home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 12 - 1996 / 12.11 Nov 96 / DebuggingStarter Code / DebuggingStarterMain.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-09  |  1.1 KB  |  57 lines  |  [TEXT/CWIE]

  1. /*________________________________________________________________________________
  2.     Sample main program to demonstrate Debug
  3. ________________________________________________________________________________*/
  4.  
  5.  
  6.     static void
  7. InitMac()
  8. {
  9.     UnloadScrap();
  10.     
  11.     InitGraf( &qd.thePort);
  12.     InitFonts();
  13.     InitWindows();
  14.     InitMenus();
  15.     TEInit();
  16.     InitDialogs( nil );
  17.     InitCursor();
  18.     MaxApplZone();
  19. }
  20.  
  21.  
  22.     void
  23. main(void)
  24.     {
  25.     Handle    theHandle;
  26.     
  27.     InitMac();
  28.     
  29.     DebugLeaks_Init();
  30.     
  31.     // start tracking leaks here
  32.     // remember: code is not implemented; this is purely for example purposes
  33.     #define kNumItemsToRemember        100UL
  34.     DebugLeaks_StartSession( kNumItemsToRemember, "\pmain");    
  35.     
  36.     
  37.     // should result in an assert
  38.     theHandle    = nil;
  39.     AssertHandleIsValid( theHandle, "\pmain");
  40.     
  41.     // should result in an assert
  42.     // interesting unrelated fact: values between 0 and -32 work due to a bug in NewHandle
  43.     theHandle    = NewHandle( -100 );
  44.     
  45.     // should result in an assert
  46.     DisposeHandle( theHandle );
  47.  
  48.  
  49.     // will report any leaks (once the code is implemented)
  50.     DebugLeaks_StopSession( );
  51.     }
  52.     
  53.     
  54.     
  55.     
  56.  
  57.